﻿@model ConferenceRegister.Models.AdminModel

@{
    ViewBag.Title = "Conference Registrants";
    RegisterService service = new RegisterService();
 }


@Html.Partial("_Conference", @Model.SelectedConference)

<h1>Conference <span>Registrants</span></h1>

@using (Html.BeginForm(null, null, FormMethod.Post, new { @class = "fast-post" }))
{
    <div>
        @Html.DropDownListFor(e => e.SelectedConferenceID, Model.Conferences)
        @Html.ValidationMessageFor(e => e.SelectedConferenceID)
        @*<input type="submit" value="Apply" />*@
    </div>

}

<table id="data">
    <thead>
    <tr>
        <th>ID</th><th>First</th><th>Last</th><th>City</th><th>State</th><th>Country</th><th>Zip</th><th>Phone</th><th>Submit</th><th>Paid</th><th>Date</th><th>Overdue (days)</th><th>Delivered</th>
        <th></th>
    </tr>
        </thead>
    <tbody>
@foreach (var item in Model.Matches) {
    <tr>
        @*@{ int daysUnpaid = (int)((@item.PaymentAmount >= @Model.SelectedConference.Cost ? (@item.PaymentDate.Value-DateTime.Now).TotalDays : (DateTime.Now-@item.SubmitDate).TotalDays) + .5);
        *@
        <td>@item.ID</td><td>@item.FirstName</td><td>@item.LastName</td><td>@item.City</td><td>@item.State</td><td>@item.Country</td><td>@item.Zip</td><td>@item.MobilePhone</td><td>@Html.DisplayFor(m=>item.SubmitDate)</td><td>@String.Format("₹{0:N0}", @item.PaymentAmount)</td><td>@Html.DisplayFor(m=>item.PaymentDate)</td><td>@service.UnpaidDays(@item, @Model.SelectedConference)</td><td>@Html.DisplayFor(m=>item.DeliverDate)</td>
        <td>
            @Html.ActionLink("Edit", "EditRegistrant", new { id=item.ID })
        </td>
    </tr>
}
</tbody>
</table>

@helper FormatDateTime(DateTime? date)
{
    if (date.HasValue) { @date.Value.ToShortDateString() }
}

@section Scripts {
    @*@Scripts.Render("~/bundles/jquery")*@
    @Scripts.Render("~/bundles/datatables")
    @*@Styles.Render("~/Content/datatables/css")*@
    
    <script>
        $(".fast-post select").change(function () {
            $(this).closest('form').submit();
        });
        $(document).ready(function () {
            var table = $('#data').dataTable({
                "oLanguage": {
                    "sSearch": "Search",
                    "sInfo": "Showing _START_-_END_ (_TOTAL_)",
                    "sLengthMenu": "_MENU_",
                },
                //"sDom": 'T<"clear">lfrtip'
                //"aoColumnDefs": [
                //        { "bVisible": false, "aTargets": [0] }
                //]
            });
           // table.columnFilter();
            //new FixedHeader(table);


        });
    </script>
}

